home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1994 December
/
PSL Monthly Shareware CD-ROM (Public Software Library)(December 1994).bin
/
prgmming
/
dos
/
asm
/
genkmaca.asm
< prev
next >
Wrap
Assembly Source File
|
1985-05-19
|
16KB
|
607 lines
;-----------------------------------------------------------------------
;
; Assembly Language Macros Version 0.1
; Written by: Malcolm McCorquodale III Houston, Texas 713-626-4979
;
; (c) 1984 by Malcolm McCorquodale III All commercial rights reserved.
;
; This software is distributed using the "FREE-SOFTWARE" concept.
; If you find these macros useful send whatever contribution you
; deem appropriate to:
;
; Malcolm McCorquodale III
; 3470 Locke Lane,
; Houston Texas 77027.
; (713) 626 - 4979
;
;-----------------------------------------------------------------------
;;-----------------------------------------------------------------------
;;
;; General Purpose Macros
;;
;;-----------------------------------------------------------------------
;;-----------------------------------------------------------------------
;;
;; SAVE <p1,..,p8> Pushes 1 to 8 parameters.
;; Parameters p2 through p8 are optional.
;;
;;-----------------------------------------------------------------------
SAVE MACRO P1,P2,P3,P4,P5,P6,P7,P8
IRP X,<P1,P2,P3,P4,P5,P6,P7,P8>
IFNB <X>
PUSH X
ENDIF
ENDM
ENDM
;;-----------------------------------------------------------------------
;;
;; RESTORE <p1,..,p8> Pops 1 to 8 parameters.
;; Parameters p2 through p8 are optional.
;;
;;-----------------------------------------------------------------------
RESTORE MACRO P1,P2,P3,P4,P5,P6,P7,P8
IRP X,<P1,P2,P3,P4,P5,P6,P7,P8>
IFNB <X>
POP X
ENDIF
ENDM
ENDM
;;-----------------------------------------------------------------------
;;
;; PRINT <msg> - Writes msg on the screen.
;;
;; No registers destroyed.
;;
;;-----------------------------------------------------------------------
PRINT MACRO MSG ; Print message on the screen.
LOCAL TEXT,PEXIT
SAVE DS,DX
MOV DX,CS
MOV DS,DX
MOV DX,OFFSET TEXT
MOV AH,9
INT 21H
RESTORE DX,DS
JMP PEXIT
TEXT DB MSG,'$'
PEXIT:
ENDM
;;-----------------------------------------------------------------------
;;
;; The macros below this point have not been fully tested. MM.
;;
;;-----------------------------------------------------------------------
;;-----------------------------------------------------------------------
;;
;; TERMINATE - End program and return to caller.
;;
;;-----------------------------------------------------------------------
TERMINATE MACRO ; End of program.
INT 20H
ENDM
;;-----------------------------------------------------------------------
;;
;; RWABS <rw>,<drive>,<nofsect>,<beg>
;; <rw> - 'R' for read, 'W' for write.
;; <drive> - drive number.
;; <nofsect> - number of sectors to transfer.
;; <beg> - Begining logical sector number.
;;
;; Read and write absolute sectors.
;;
;; Note: 1) Status information is returned in flags, After the
;; flags are sampled they should be poped off the stack
;; with a POPF.
;;
;; 2) DS:DX must point to the DTA before this call.
;;
;;-----------------------------------------------------------------------
RWABS MACRO RW,DRIVE,NOFSECT,BEG ; R/W absolute disk sector.
SAVE BX,CX,DX
MOV AL,DRIVE
MOV CX,NOFSECT
MOV DX,BEG
IFIDN <RW>,<'R'>
INT 25H
ENDIF
IFIDN <RW>,<'W'>
INT 26H
ENDIF
RESTORE DX,CX,BX
ENDM
;;-----------------------------------------------------------------------
;;
;; ADDTODOS <dosend> - Add the current proc to DOS.
;;
;; Note: <dosend> is a label at the highest memory address
;; used by your code.
;;
;;-----------------------------------------------------------------------
ADDTODOS MACRO DOSEND ; Add a procedure to DOS.
MOV DX,DOSEND
INC DX
INT 27H
ENDM
;;-----------------------------------------------------------------------
;;
;; DOSRS232 <char>
;; Sends or receives a <char> to/from the standard RS232 port.
;;
;; If <char> is specified then it is sent to the RS232 port.
;; If <char> is not specified then a character is read into AL.
;;
;; OUTPUT: If receiving data AL will contain the byte received.
;;
;; All registers saved.
;;
;;-----------------------------------------------------------------------
DOSRS232 MACRO CHAR
SAVE AH,DL
IFB <CHAR>
MOV AH,3 ; Receive a character from the RS232 port.
ELSE
MOV AH,4 ; Send a character to the RS232 port.
ENDIF
INT 21H
RESTORE DL,AH
ENDM
;;-----------------------------------------------------------------------
;;
;; PRINT1 <char> - Send <char> to the standard printer.
;;
;; No registers destroyed.
;;
;;-----------------------------------------------------------------------
PRINT1 MACRO CHAR ; Send a character to the printer.
SAVE AH,DL
MOV DL,CHAR
MOV AH,5
INT 21H
RESTORE DL,AH
ENDM
;;-----------------------------------------------------------------------
;;
;; INPUTSTR <len>,<bufoff>,[<bufseg>]
;; <len> - Length of input buffer.
;; <bufoff> - Offset from <bufseg> to message buffer.
;; <bufseg> - Optional segment for input buffer.
;;
;; Input a string ending with a RETURN from the standard
;; input device.
;;
;; No registers destroyed except DS:DX which points to
;; input buffer on output.
;;
;; On exit: DS:DX will have <bufseg>:<bufoff>.
;; Byte 1 of buffer = Size of buffer.
;; Byte 2 of buffer = Number of bytes read w/o c/r.
;; Byte 3 of buffer = Start of text read.
;;
;;-----------------------------------------------------------------------
INPUTSTR MACRO LEN,BUFOFF,BUFSEG ; Get a line of text.
PUSH AH
IFNB <BUFSEG>
MOV DX,BUFSEG
MOV DS,DX
ENDIF
MOV DX,BUFOFF
MOV [DX],LEN
MOV AH,0AH
INT 21H
POP AH
ENDM
;;-----------------------------------------------------------------------
;;
;; POLLSTDIN - Check the status of the standard input device.
;;
;; On exit: AL = 0FFH - Character is available.
;; 00H - Character not available.
;;
;; Note: This routine executes an INT 23H if a ctl-brk
;; is detected.
;;
;; No registesrs destroyed.
;;
;;-----------------------------------------------------------------------
POLLSTDIN MACRO ; Poll the standard input device.
PUSH AH
MOV AH,0BH
INT 21H
POP AH
ENDM
;;-----------------------------------------------------------------------
;;
;; CLRSTDIN <func> - Clear standard input buffer then execute
;; function <func>.
;; <func> may be 1 - Keyboard input.
;; 6 - Direct Console I/O.
;; 7 - Direct Console Input w/o Echo.
;; 8 - Console Input w/o Echo.
;; A - Buffered Keyboard Input.
;;
;; No registers destroyed except AX.
;;
;;-----------------------------------------------------------------------
CLRSTDIN MACRO FUNC ; Clear the standard input device.
MOV AL,FUNC
MOV AH,0CH
INT 21H
ENDM
;;-----------------------------------------------------------------------
;;
;; DISKRESET - Flushes all file buffers.
;;
;;-----------------------------------------------------------------------
DISKRESET MACRO ; Reset the disk.
PUSH AH
MOV AH,0DH
INT 21H
POP AH
ENDM
;;-----------------------------------------------------------------------
;;
;; PICKDRIVE <drive> - Select the default disk drive.
;;
;; Input: 0 = Drive A, 1 = Drive B, etc.
;;
;; Output: AL = number of drives. Minimum=2.
;;
;; No registers destroyed.
;;
;;-----------------------------------------------------------------------
PICKDRIVE MACRO DRIVE ; Pick the default disk drive.
SAVE DL,AH
MOV DL,DRIVE
MOV AH,0EH
INT 21H
RESTORE AH,DL
ENDM
;;-----------------------------------------------------------------------
;;
;; FINDRIVE - Determine the default drive.
;;
;; Output: AL = 0 = Drive A, 1 = Drive B, etc.
;;
;; No registers destroyed except AL.
;;
;;-----------------------------------------------------------------------
FINDRIVE MACRO ; Find the default disk drive.
PUSH AH
MOV AH,19H
INT 21H
POP AH
ENDM
;;-----------------------------------------------------------------------
;;
;; SETDTA - Set the DTA.
;;
;; On input: DS:DX must poi